package s21.ch24.ex1;

public class MyWaitNotify {

	private static Object monitor = new Object();

	public static class MyThread extends Thread {

		@Override
		public void run() {
			System.out.println("jestem thread ");
			try {
				synchronized (monitor) {
					monitor.wait();
				}
			} catch (InterruptedException e) {
				System.out.println("przerwany");
			}
			System.out.println("koniec watku");
		}
	}

	public static void main(String[] args) throws Exception{
		MyThread t1 = new MyThread();
		t1.start();
		MyThread t2 = new MyThread();
		t2.start();
		synchronized (monitor) {
			monitor.notify();
			monitor.notify();
		}
	}
}